package drds.global_transaction.api.api;

import drds.common.ShouldNeverHappenException;

public enum BranchTransactionStatus
{

	unknown,

	registered_to_transaction_coordinator,

	phase_one_succeed,

	phase_one_failed,

	phase_one_not_reported_for_timeout,
	//
	phase_two_committed,

	phase_two_commit_failed_and_retriable,

	phase_two_commit_failed_and_unretriable,

	phase_two_rollbacked,

	phase_two_rollback_failed_and_retriable,

	phase_two_rollback_failed_and_unretriable;

	//
	public static BranchTransactionStatus get(byte ordinal)
	{
		return get((int) ordinal);
	}

	public static BranchTransactionStatus get(int ordinal)
	{
		for (BranchTransactionStatus branchTransactionStatus : BranchTransactionStatus.values())
		{
			if (branchTransactionStatus.ordinal() == ordinal)
			{
				return branchTransactionStatus;
			}
		}
		throw new ShouldNeverHappenException();
	}
}
